﻿namespace FastColoredTextBoxNS
{
    using System.Drawing;
    using System.Windows.Forms;

    public class VisualMarker
    {
        public readonly Rectangle rectangle;

        public VisualMarker(Rectangle rectangle)
        {
            this.rectangle = rectangle;
        }

        public virtual void Draw(Graphics gr, Pen pen)
        {
        }

        public virtual Cursor Cursor
        {
            get
            {
                return Cursors.Hand;
            }
        }
    }

    public class CollapseFoldingMarker : VisualMarker
    {
        public readonly int iLine;

        public CollapseFoldingMarker(int iLine, Rectangle rectangle)
            : base(rectangle)
        {
            this.iLine = iLine;
        }

        public override void Draw(Graphics gr, Pen pen)
        {
            //draw minus
            gr.FillRectangle(Brushes.White, this.rectangle);
            gr.DrawRectangle(pen, this.rectangle);
            gr.DrawLine(
                pen,
                this.rectangle.Left + 2,
                this.rectangle.Top + this.rectangle.Height / 2,
                this.rectangle.Right - 2,
                this.rectangle.Top + this.rectangle.Height / 2);
        }
    }

    public class ExpandFoldingMarker : VisualMarker
    {
        public readonly int iLine;

        public ExpandFoldingMarker(int iLine, Rectangle rectangle)
            : base(rectangle)
        {
            this.iLine = iLine;
        }

        public override void Draw(Graphics gr, Pen pen)
        {
            //draw plus
            gr.FillRectangle(Brushes.White, this.rectangle);
            gr.DrawRectangle(pen, this.rectangle);
            gr.DrawLine(
                Pens.Red,
                this.rectangle.Left + 2,
                this.rectangle.Top + this.rectangle.Height / 2,
                this.rectangle.Right - 2,
                this.rectangle.Top + this.rectangle.Height / 2);
            gr.DrawLine(
                Pens.Red,
                this.rectangle.Left + this.rectangle.Width / 2,
                this.rectangle.Top + 2,
                this.rectangle.Left + this.rectangle.Width / 2,
                this.rectangle.Bottom - 2);
        }
    }

    public class FoldedAreaMarker : VisualMarker
    {
        public readonly int iLine;

        public FoldedAreaMarker(int iLine, Rectangle rectangle)
            : base(rectangle)
        {
            this.iLine = iLine;
        }

        public override void Draw(Graphics gr, Pen pen)
        {
            gr.DrawRectangle(pen, this.rectangle);
        }
    }

    public class StyleVisualMarker : VisualMarker
    {
        public Style Style { get; private set; }

        public StyleVisualMarker(Rectangle rectangle, Style style)
            : base(rectangle)
        {
            this.Style = style;
        }
    }

    public class VisualMarkerEventArgs : MouseEventArgs
    {
        public Style Style { get; private set; }

        public StyleVisualMarker Marker { get; private set; }

        public VisualMarkerEventArgs(Style style, StyleVisualMarker marker, MouseEventArgs args)
            : base(args.Button, args.Clicks, args.X, args.Y, args.Delta)
        {
            this.Style = style;
            this.Marker = marker;
        }
    }
}